//
//  SXTTabBarViewController.h
//
//
//  Created by ma c on 16/8/18.
//
//

#import "SXTNavgationController.h"

@interface SXTNavgationController ()

@end

@implementation SXTNavgationController

//保证只对navbar进行一次设置,节约性能
+(void)initialize {

    UINavigationBar * navBar = [UINavigationBar appearance];
    //设置navBar的背景图片
    [navBar setBackgroundImage:[UIImage imageNamed:@"nav_backImage"] forBarMetrics:(UIBarMetricsDefault)];
    //设置导航栏样式
    [navBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20.0f]
                                     }];

}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {

    if (self.childViewControllers.count) {
        UIButton * backBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        backBtn.frame = CGRectMake(0, 0, 30, 30);
        [backBtn setImage:[UIImage imageNamed:@"详情界面返回按钮"] forState:(UIControlStateNormal)];
        [backBtn addTarget:self action:@selector(returnViewController) forControlEvents:(UIControlEventTouchUpInside)];
        
        UIBarButtonItem * backItem = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
        viewController.navigationItem.leftBarButtonItem = backItem;
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}
-(void)returnViewController {

    [self popViewControllerAnimated:YES];
}












@end
